# coding: utf-8
import random

import web

from libs import utils
from libs.utils import render, require_captcha, set_self_user, db


class index:
    @set_self_user
    def GET(self):
        articles = db.select('article', order='id desc')

        return render('index', action=self, articles=articles)

    @require_captcha
    def POST(self):
        post = web.input()

        content = post.content

        web.header('Content-Type', 'text/html; charset=utf-8')

        return "验证码识别正确：" + content
